<template>
  <div>
    <el-upload
      class="upload-demo"
      drag
      action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
      multiple
    >
      <el-icon class="el-icon--upload"><upload-filled /></el-icon>
      <div class="el-upload__text">
        点击或将文件拖拽到这里上传<br />
        支持Excel、CSV文件
      </div>
    </el-upload>
    <div>
      <FilterBox v-model="queryParams" @search="search" />
      <pure-table
        :data="tableData"
        :columns="columns"
        stripe
        max-height="calc(100vh - 420px)"
      >
        <template #action="{ row }">
          <el-button type="primary" link @click="handleDownload(row)">
            下载
          </el-button>
          <el-button type="danger" link @click="handleDelete(row)"
            >删除</el-button
          >
        </template>
      </pure-table>
      <div class="filterBox">
        <el-pagination
          v-model:current-page="queryParams.currentPage"
          v-model:page-size="queryParams.pageSize"
          layout=" prev, pager, next, sizes, total"
          :total="20"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { UploadFilled } from "@element-plus/icons-vue";
import FilterBox from "./components/searchForm.vue";
import { ref } from "vue";
import { columns, tableData } from "./data";

const queryParams = ref({
  year: "",
  fileName: "",
  dateRange: [],
  currentPage: 1,
  pageSize: 10
});

const search = () => {
  console.log(queryParams.value);
};
const handleDownload = (row: any) => {
  console.log(row);
};

const handleDelete = (row: any) => {
  console.log(row);
};

const handleSizeChange = (val: number) => {
  console.log(`每页 ${val} 条`);
};

const handleCurrentChange = (val: number) => {
  console.log(`当前页: ${val}`);
};

defineOptions({ name: "dataImport" });
</script>
<style scoped>
.el-link {
  margin-right: 8px;
}
</style>
